package com.rimi.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.rimi.bean.Attentions;
import com.rimi.bean.User;
import com.rimi.service.AttentionsService;
import com.rimi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * InnoDB free: 11264 kB; (`user_id`) REFER `owl_video/user`(`user_id`) 前端控制器
 * </p>
 *
 * @author sky
 * @since 2018-06-06
 */
@Controller
@RequestMapping("/attentions")
public class AttentionsController {

    @Autowired
    private AttentionsService attentionsService;

    @Autowired
    private UserService userService;

    @RequestMapping("/user")
    public String attention(Model model , Integer userId){
        User user=new User();
        userId = user.getUserId();
        List<Attentions> attentions = attentionsService.selectList(new EntityWrapper<Attentions>().eq("user_id",userId));
        List<User> list = new ArrayList();
        for (Attentions attention : attentions) {
            user = userService.selectById(attention.getAttentionId());
            list.add(user);
        }
        model.addAttribute("attention",list);
        return "personal_center1111";

    }

}

